<%@ include file="/WEB-INF/jsp/init.jsp" %>

<h1>Add / Edit Form</h1>

<% 
	PortletURL addBookURL = renderResponse.createActionURL();
	addBookURL.setParameter("action", "addBook");

	PortletURL updateBookURL = renderResponse.createActionURL();
	updateBookURL.setParameter("action", "updateBook");
	
	String url = addBookURL.toString();
	
	LMSBook book = new LMSBookImpl();
	long bookId = ParamUtil.getLong(request, "bookId");
	if (bookId > 0L) {
		book = LMSBookLocalServiceUtil.getLMSBook(bookId);
        url = updateBookURL.toString();
	}
		
%>

<aui:form name="fm" method="POST" action="<%= url.toString() %>" >
	<aui:input type="hidden" name="redirectURL" value="<%= renderResponse.createRenderURL().toString() %>"/>
	<aui:input type="hidden" name="bookId" value="<%= String.valueOf(book.getBookId()) %>"/>
	<aui:input name="bookTitle" label="Book Title" value="<%= book.getBookTitle() %>"/>
	<aui:input name="author" label="Author" value="<%= book.getAuthor() %>"/>
	<aui:button type="submit" value="Save"/>
</aui:form>

<br/><a href="<portlet:renderURL/>">&laquo; Go Back</a>